<?php
namespace Member\Controller;
use Think\Controller;

class MemberController extends Controller {
	
	function _initialize() {
		define('UID', is_login());
		if(!UID){// 还没登录 跳转到登录页面
			set_redirect_url(U('/Member') );
			$this->redirect('/login');
		}
		/* 读取数据库中的配置 */
		$config =   S('DB_CONFIG_DATA');
		if(!$config){
			$config =   api('Config/lists');
			S('DB_CONFIG_DATA',$config);
		}
		C($config); //添加配置
		$this->title();
	}
	
	protected function title($title = '') {
		$this->assign('mini_title', $title);
		!empty($title) && $title = $title.' - ';
		$this->assign('meta_title', $title. '管理中心 - ' . C('WEB_SITE_TITLE'));
	}
	
	protected function oFind($model, $id) {
		$res = M($model)->find($id);
		if ($res['uid'] != UID) {
			$this->error('没有权限执行此操作！');
		}else {
			return $res;
		}
	}
}